import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

import 'FavoritePage.dart';
import 'HistoryPage.dart';
import 'HomePage.dart';
import 'MyPage.dart';


class TabBarPage extends StatelessWidget {
  final SystemUiOverlayStyle _style = SystemUiOverlayStyle(statusBarColor: Colors.transparent);
  @override
  Widget build(BuildContext context) {
    SystemChrome.setSystemUIOverlayStyle(_style);
    // TODO: implement build
    return MaterialApp(
      home: TabBarStatefulWidget(),
      theme: ThemeData(primarySwatch: Colors.yellow),
    );
  }
}

class TabBarStatefulWidget extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    // TODO: implement createState
    return _TabBarState();
  }
}

class _TabBarState extends State<StatefulWidget> {

  List _tabbarTitles = ["推荐","关注","财经","房产"];

  TabController _controller;

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    _controller = TabController(length: _tabbarTitles.length, vsync: null);
  }

  @override
  void dispose() {
    // TODO: implement dispose
    super.dispose();
  }
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Scaffold(
      appBar: AppBar(
        title: Text("TabBar Page"),
        elevation: 0,
        bottom: TabBar(
          controller: _controller,
          tabs: _tabbarTitles.map((t) => Tab(text: t,)).toList(),
        ),
      ),
      body: TabBarView(children:[
        HomePage(),
        FavoritePage(),
        HistoryPage(),
        MyPage(),
      ]),
    );
  }
}